/*   1:    */ package com.atomikos.swing;
/*   2:    */ 
/*   3:    */ import java.awt.GridLayout;
/*   4:    */ import java.beans.PropertyChangeEvent;
/*   5:    */ import java.beans.PropertyChangeListener;
/*   6:    */ import java.io.PrintStream;
/*   7:    */ import javax.swing.JDialog;
/*   8:    */ import javax.swing.JFrame;
/*   9:    */ import javax.swing.JLabel;
/*  10:    */ import javax.swing.JOptionPane;
/*  11:    */ import javax.swing.JPanel;
/*  12:    */ import javax.swing.JPasswordField;
/*  13:    */ import javax.swing.JTextField;
/*  14:    */ 
/*  15:    */ public class LoginDialog
/*  16:    */   extends JDialog
/*  17:    */ {
/*  18:    */   private JTextField name_;
/*  19:    */   private JPasswordField passwd_;
/*  20:    */   private boolean valid_;
/*  21:    */   
/*  22:    */   public LoginDialog(JFrame frame, String title, String message)
/*  23:    */   {
/*  24: 66 */     super(frame, title, true);
/*  25:    */     
/*  26: 68 */     this.name_ = new JTextField(8);
/*  27: 69 */     JLabel nameLabel = new JLabel("Username");
/*  28: 70 */     this.passwd_ = new JPasswordField(8);
/*  29: 71 */     JLabel passwdLabel = new JLabel("Password");
/*  30:    */     
/*  31:    */ 
/*  32: 74 */     JPanel panel = new JPanel();
/*  33: 75 */     panel.setLayout(new GridLayout(0, 1));
/*  34:    */     
/*  35: 77 */     JLabel label2 = new JLabel(message);
/*  36:    */     
/*  37: 79 */     panel.add(label2);
/*  38: 80 */     panel.add(nameLabel);panel.add(this.name_);
/*  39: 81 */     panel.add(passwdLabel);panel.add(this.passwd_);
/*  40: 82 */     this.valid_ = false;
/*  41: 83 */     String connect = "Connect";
/*  42: 84 */     String cancel = "Cancel";
/*  43: 85 */     String[] options = { "Connect", "Cancel" };
/*  44: 86 */     final JOptionPane optionPane = new JOptionPane(panel, -1, 2, null, options, options[0]);
/*  45:    */     
/*  46:    */ 
/*  47: 89 */     setContentPane(optionPane);
/*  48: 90 */     setDefaultCloseOperation(0);
/*  49: 91 */     optionPane.addPropertyChangeListener(new PropertyChangeListener()
/*  50:    */     {
/*  51:    */       public void propertyChange(PropertyChangeEvent e)
/*  52:    */       {
/*  53: 94 */         if ((LoginDialog.this.isVisible()) && (e.getSource() == optionPane))
/*  54:    */         {
/*  55: 95 */           if (optionPane.getValue() == "Connect") {
/*  56: 96 */             LoginDialog.this.valid_ = true;
/*  57:    */           }
/*  58: 97 */           LoginDialog.this.setVisible(false);
/*  59: 98 */           LoginDialog.this.dispose();
/*  60:    */         }
/*  61:    */       }
/*  62:102 */     });
/*  63:103 */     setSize(250, 220);
/*  64:    */   }
/*  65:    */   
/*  66:    */   public String getUserName()
/*  67:    */   {
/*  68:116 */     return this.name_.getText();
/*  69:    */   }
/*  70:    */   
/*  71:    */   public String getPassword()
/*  72:    */   {
/*  73:127 */     return new String(this.passwd_.getPassword());
/*  74:    */   }
/*  75:    */   
/*  76:    */   public boolean isValid()
/*  77:    */   {
/*  78:138 */     return this.valid_;
/*  79:    */   }
/*  80:    */   
/*  81:    */   public static void main(String[] args)
/*  82:    */   {
/*  83:    */     try
/*  84:    */     {
/*  85:145 */       JFrame frame = new JFrame("Test");
/*  86:146 */       LoginDialog dialog = new LoginDialog(frame, "Test", "Test");
/*  87:147 */       dialog.show();
/*  88:148 */       if (dialog.isValid()) {
/*  89:149 */         System.out.println("User entered " + dialog.getUserName() + "/" + dialog.getPassword());
/*  90:    */       }
/*  91:    */     }
/*  92:    */     catch (Exception e)
/*  93:    */     {
/*  94:154 */       e.printStackTrace();
/*  95:    */     }
/*  96:    */     finally
/*  97:    */     {
/*  98:157 */       System.exit(0);
/*  99:    */     }
/* 100:    */   }
/* 101:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\atomikos-util\3.7.0\atomikos-util-3.7.0.jar
 * Qualified Name:     com.atomikos.swing.LoginDialog
 * JD-Core Version:    0.7.0.1
 */